const {Service}=require("egg")
const axios =require("axios")

class codeService extends Service{

    async upLoad({id,imgurl}){
        const sql=`update login set avatar=? where id=?`
        return await this.app.mysql.query(sql,[imgurl,id])
    }

    async getAccess(access_token){
        const result=axios.get("https://gitee.com/api/v5/user",{params:{access_token}})
        return result
    }

    async getCodegit(gitcode){
        const result=axios.post("https://gitee.com/oauth/token",{
            grant_type:"authorization_code",
            code:gitcode,
            client_id:"1dc6f91fb93c8a8a8f6051a0ffd83e32313ab6caf64d5fa13a70869277b951b4",
            redirect_uri:"http://localhost:8080/home/index",
            client_secret:"eac764297c3defddbf1f1909ae35d1357d7d2bf36797e96b5606606f02a28771"
        })
        return result
    }
}

module.exports=codeService